#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from kazoo.client import KazooClient

zk = KazooClient(hosts='127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183')
zk.start()
# Ensure a path, create if necessary
zk.ensure_path("/my/favorite")

node = "/my/favorite/node"

if not zk.exists(node):
    # Create a node with data
    zk.create(node, b"a value")
else:
    print('node %s has already exist!' % node)

zk.stop()
